import React from 'react';
import {View, Text, Button, StyleSheet} from 'react-native';

export default class HomeScreen extends React.Component {
  componentDidMount() {
    if (__DEV__) {
      // eslint-disable-next-line no-undef
      GLOBAL.XMLHttpRequest =
        // eslint-disable-next-line no-undef
        GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
    } else {
      global.console = {
        info: () => {},
        log: () => {},
        warn: () => {},
        debug: () => {},
        error: () => {},
      };
    }
  }
  getData = () => {
    fetch('https://api.apiopen.top/singlePoetry')
      .then(res => res.json())
      .then(res => {
        console.log(res.data);
      })
      .catch(e => {
        console.log(e);
      });
  };
  render() {
    return (
      // eslint-disable-next-line react-native/no-inline-styles
      <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
        <Text style={styles.font} onPress={this.getData}>
          Home Screen
        </Text>
        <Button
          title="Go to Details"
          onPress={() => this.props.navigation.navigate('Details')}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  font: {
    fontSize: 30,
    margin: 20,
  },
});
